package com.springmvc.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.alibaba.fastjson.JSON;
import com.springmvc.model.User;
import com.springmvc.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {
	private Logger logger = Logger.getLogger(UserController.class);
	@Resource
	private IUserService userService;
	@RequestMapping("/showUser")
	public ModelAndView showUser(HttpServletRequest request,String id,Model model,ModelAndView modelAndView,RedirectAttributes reAttributes){
//		long userId = Long.parseLong(request.getParameter("id"));  
//        User user = this.userService.selectByPrimaryKey(userId);  
//        logger.info(JSON.toJSONString(user));
		User user = new User();
		user.setUsername("asdf");
        modelAndView.addObject("name", user.getUsername());
        reAttributes.addAttribute("name", user.getUsername());
        reAttributes.addAttribute("aaa","aaa");
        modelAndView.setViewName("redirect:/1.html");
		return modelAndView;
		
	}
	
}
